package day11;

public class TestAnonyInnerClass {
	private int i = 10;
	private Animal a = new Animal("animal");
	private IB ib = new IB(){
		public void show(){
			System.out.println("IB show");
		}
	};
	public static void main(String[] args) {
		IB ib = AnonyOuter.getIB();
		ib.show();
		AbsClass ac = AnonyOuter.getAbsClass();
		ac.show();
		Animal a = AnonyOuter.getAnimal();
		a.eat();
	}
}
interface IB{
	void show();
}
abstract class AbsClass{
	public abstract void show();
}
class Animal{
	private String name;
	public String getName(){
		return name;
	}
	public Animal(String name){
		this.name = name;
	}
	public void eat(){
		System.out.println(name+" animal eat");
	}
}
class Dog extends Animal{
	public Dog(String name){
		super(name);
	}
}
class AnonyOuter{
	public static IB getIB(){
		IB ib = new IB(){
			public void show(){
				System.out.println("haha");
			}
		};
		return ib;
	}
	public static AbsClass getAbsClass(){
		return new AbsClass(){
			public void show(){
				System.out.println("AbsClassShow()");
			}
		};
	}
	public static Animal getAnimal(){
		int i1 = 10;
		final int fi = 20;
		return new Animal("WangCai"){
			private int i = 10;
			{
				System.out.println("start");
			}
			public void show(){
			//	System.out.println(i1);
				System.out.println(fi);
			}
			public void eat(){
				System.out.println(getName()+" dog eat bone");
			}
		};
	}
}
